﻿using System.Collections.Generic;

namespace IceCS.DesignPattern.Core.CompositeEntityPattern.JavaEJB
{
    /// <summary>
    /// 粗粒度对象（Coarse-Grained Object） - 该对象包含依赖对象。它有自己的生命周期，也能管理依赖对象的生命周期。
    /// </summary>
    public class CoarseGrainedObject
    {
        private DependentObject1 do1;
        private DependentObject2 do2;

        public CoarseGrainedObject()
        {
            do1 = new DependentObject1();
            do2 = new DependentObject2();
        }

        public List<string> GetData()
        {
            return new List<string> { do1.Data, do2.Data };
        }

        public void SetData(string data1, string data2)
        {
            do1.Data = data1;
            do2.Data = data2;
        }
    }
}
